package Util

import (
	"encoding/json"
	"io/ioutil"
)

type Config struct {
	App struct {
		AppName string `json:"appName"`
	} `json:"app"`
	Server struct {
		Address string `json:"address"`
		Port    string `json:"port"`
	} `json:"server"`
}

func ReadJson(path string) *Config {
	bytes, err := ioutil.ReadFile(path)
	if err != nil {
		panic("读取配置文件发生错误")
	}
	var config Config
	err = json.Unmarshal(bytes, &config)
	if err != nil {
		panic("解码文件发生错误")
	}
	return &config
}
